

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;

import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Insets;
import javax.swing.JTextArea;
import javax.swing.JScrollBar;


public class CategoryUpdateFrame extends JFrame {
	
	private static final long serialVersionUID = 1L;
	private JPanel contentPane;
	private JTextField textField;
	private JTextField categoryField;
	private JTextField textField_2;
	private JTextField textField_3;
	private JTextField textField_1;
	private JTable table;
	private JTable table_1;
	private JTable table_2;
	private JTextField numberField;
	private JTextField textField_4;
	private JTextField textField_5;
	private JTextField nameField;
	private JTextField textField_9;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					CategoryUpdateFrame frame = new CategoryUpdateFrame();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public CategoryUpdateFrame() {
		setTitle("商品维护");
		//设置窗体位置与大小
		setBounds(100, 100, 450, 300);
		//设置关闭操作的事件
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		//固定窗口大小
		setSize(600,800);
		//设置窗口的位置为居中显示
		setLocationRelativeTo(null);
		getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
		
		JPanel panel = new JPanel();
		getContentPane().add(panel);
		panel.setLayout(new FlowLayout(FlowLayout.CENTER, 10, 10));
		
		//第一布局内容：
		JLabel categoryLabel = new JLabel("商品类别名称");
		panel.add(categoryLabel);
		
		categoryField = new JTextField();
		categoryField.setColumns(10);
		panel.add(categoryField);
		
		
		JButton searchButton = new JButton("查询");
		panel.add(searchButton);
		
		//第二布局内容：
		String[] columnNames = {"编号","商品类别名称","商品类别描述"};
		Object[][] data= {{"2","食品类","好吃"},
				{"3","书本类","益智"},
				{"4","手机类","手机电子"},
				{"5","电脑类","电脑产品"},
				{"7","服装类","服装衣服"}};
		//创建
		DefaultTableModel model=new DefaultTableModel(data,columnNames);
		JTable table=new JTable(model);
		JScrollPane tablePanel=new JScrollPane(table);
		getContentPane().add(tablePanel);
		
		
		
		
		//第三布局内容：
		JPanel formPanel = new JPanel();
		getContentPane().add(formPanel);
		GridBagLayout gbl_formPanel = new GridBagLayout();
		formPanel.setLayout(gbl_formPanel);
		
		JLabel numberLabel = new JLabel("编号");
		GridBagConstraints gbc_numberLabel = new GridBagConstraints();
		gbc_numberLabel.anchor = GridBagConstraints.EAST;
		gbc_numberLabel.insets = new Insets(0, 0, 5, 5);
		gbc_numberLabel.gridx = 0;
		gbc_numberLabel.gridy = 0;
		formPanel.add(numberLabel, gbc_numberLabel);
		
		numberField = new JTextField();
		GridBagConstraints gbc_numberField= new GridBagConstraints();
		gbc_numberField.insets = new Insets(0, 0, 5, 5);
		gbc_numberField.fill = GridBagConstraints.HORIZONTAL;
		gbc_numberField.gridx = 1;
		gbc_numberField.gridy = 0;
		formPanel.add(numberField, gbc_numberField);
		numberField.setColumns(10);
		
		JLabel nameLabel = new JLabel("商品类别名称");
		GridBagConstraints gbc_nameLabel = new GridBagConstraints();
		gbc_nameLabel.insets = new Insets(0, 0, 5, 5);
		gbc_nameLabel.gridx = 2;
		gbc_nameLabel.gridy = 0;
		formPanel.add(nameLabel, gbc_nameLabel);
		
		nameField = new JTextField();
		GridBagConstraints gbc_nameField = new GridBagConstraints();
		gbc_nameField.gridwidth = 2;
		gbc_nameField.insets = new Insets(0, 0, 5, 5);
		gbc_nameField.fill = GridBagConstraints.HORIZONTAL;
		gbc_nameField.gridx = 3;
		gbc_nameField.gridy = 0;
		formPanel.add(nameField, gbc_nameField);
		nameField.setColumns(10);
		
		JLabel describeLabel = new JLabel("描述");
		GridBagConstraints gbc_describeLabel = new GridBagConstraints();
		gbc_describeLabel.insets = new Insets(0, 0, 5, 5);
		gbc_describeLabel.gridx = 0;
		gbc_describeLabel.gridy = 1;
		formPanel.add(describeLabel, gbc_describeLabel);
		
		JTextArea describeArea = new JTextArea();
		describeArea.setRows(10);
		GridBagConstraints gbc_describeArea = new GridBagConstraints();
		gbc_describeArea.gridheight = 3;
		gbc_describeArea.gridwidth = 4;
		gbc_describeArea.insets = new Insets(0, 0, 5, 5);
		gbc_describeArea.fill = GridBagConstraints.BOTH;
		gbc_describeArea.gridx = 1;
		gbc_describeArea.gridy = 1;
		formPanel.add(describeArea, gbc_describeArea);
		
		JButton repairButton = new JButton("修改");
		GridBagConstraints gbc_repairButton = new GridBagConstraints();
		gbc_repairButton.insets = new Insets(0, 0, 0, 5);
		gbc_repairButton.gridx = 1;
		gbc_repairButton.gridy = 4;
		formPanel.add(repairButton, gbc_repairButton);
		
		JButton deleteButton_2 = new JButton("删除");
		deleteButton_2.setIcon(new ImageIcon("./images/delete.png"));
		GridBagConstraints gbc_deleteButton_2 = new GridBagConstraints();
		gbc_deleteButton_2.insets = new Insets(0, 0, 0, 5);
		gbc_deleteButton_2.gridx = 4;
		gbc_deleteButton_2.gridy = 4;
		formPanel.add(deleteButton_2, gbc_deleteButton_2);
		
	
	}

}
